﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DataFetchTool
{
    public partial class HostDialog : Form
    {
        public HostDialog()
        {
            InitializeComponent();
        }

        private void ConfirmBtn_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        private void RemoveText(object sender, EventArgs e)
        {
            if ("例：127.0.0.1".Equals(this.textBox1.Text))
            {
                this.textBox1.Text = "";
            }
        }

        public string GetValue()
        {
            if ("例：127.0.0.1".Equals(this.textBox1.Text))
            {
                return "";
            }
            return this.textBox1.Text;
        }

        public void SetValue(string value)
        {
            if (!string.IsNullOrWhiteSpace(value))
            {
                this.textBox1.Text = value;
            }
        }

        public void EnterAddress(object sender, PreviewKeyDownEventArgs e)
        {

            if (e.KeyCode == Keys.Enter)
            {
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }
    }
}
